//
// Created by 123 on 2024/12/31.
//
#include "iostream"
using namespace std;

class Person{
public:
    static int m_a;
    int m_c;
    static void func(){
        cout << "func invoke..." << endl;
        m_a = 100;
//        m_c = 200;//不可以访问非静态成员变量
    }
private:
    static int m_b;
    static void func2(){
        cout << "private func invoke" << endl;
    }
};
//初始化类的静态成员变量
int Person::m_a = 10;
int Person::m_b = 10;

void test(){
    //静态成员变量的两种访问方式
    //1-通过对象访问
    Person p1;
    Person p2;
    cout << "p1.m_a==" << p1.m_a << endl;
    cout << "p2.m_a==" << p2.m_a << endl;
    p1.m_a = 100;
    cout << "p1.m_a==" << p1.m_a << endl;
    cout << "p2.m_a==" << p2.m_a << endl;

    //2-通过类名访问
    cout << "m_a==" << Person::m_a << endl;
}

int main064(){
//    test();
    Person p;
    p.func();
    Person::func();

    return 0;
}